﻿ using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAO;
using BUS;

namespace OnlineDigitalCameraWebsite.Class
{
    public class ProductCart
    {
        public override string ToString()
        {
            return _name;
        }

        private int _productId = 0;
        /// <summary>
        /// The Product ID
        /// </summary>
        public int ProductId
        {
            get
            {
                return _productId;
            }
            set
            {
                _productId = value;
            }
        }

        private string _productCategory = "";
        public string ProductCategory
        {
            get
            {
                return _productCategory;
            }
            set
            {
                _productCategory = value;
            }
        }


      

        private string _name = "";
        /// <summary>
        /// Product Name
        /// </summary>
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }

        private string _description = "";
        /// <summary>
        /// Product Name
        /// </summary>
        public string Description
        {
            get
            {
                return _description;
            }
            set
            {
                _description = value;
            }
        }

   
        private string _image = "";
        public string Image
        {
            get
            {
                return _image;
            }
            set
            {
                _image = value;
            }
        }

       
        private decimal _price = 0M;
        /// <summary>
        /// Price charging for product
        /// </summary>
        public decimal Price
        {
            get
            {
                return _price;
            }
            set
            {
                _price = value;
            }
        }

        
        public ProductCart()
        {

        }

        public ProductCart(int productId)
        {
            //string cate =  Session["ProductCategory"].ToString();
            if (this.ProductCategory == "accessories")
            {
                AccessoriesBUS db = new AccessoriesBUS();
                Accessory obj = db.GetById(productId);
                this.ProductId = obj.accesId;
                this.Name = obj.accesNames;
                this.Description = obj.accesDetails;
                this.Image = obj.accesImages;
                this.Price = decimal.Parse(obj.accesPrice.ToString());
            }
            else if (this.ProductCategory == "lens")
            {
                LensBUS db = new LensBUS();
                Lens obj = db.GetById(productId);
                this.ProductId = obj.lensId;
                this.Name = obj.lensNames;
                this.Description = obj.lensDetails;
                this.Image = obj.lensImages;
                this.Price = decimal.Parse(obj.lensPrice.ToString());
            }
            else
            {
                CameraBUS db = new CameraBUS();
                Camera obj = db.GetById(productId);
                this.ProductId = obj.camId;
                this.Name = obj.camNames;
                this.Description = obj.camDetails;
                this.Image = obj.camImages;
                this.Price = decimal.Parse(obj.camPrice.ToString());
            }

        }
        public ProductCart(int productId, string cate)
        {
            this.ProductCategory = cate;
            //string cate =  Session["ProductCategory"].ToString();
            if (this.ProductCategory == "accessories")
            {
                AccessoriesBUS db = new AccessoriesBUS();
                Accessory obj = db.GetById(productId);
                this.ProductId = obj.accesId;
                this.Name = obj.accesNames;
                this.Description = obj.accesDetails;
                this.Image = obj.accesImages;
                this.Price = decimal.Parse(obj.accesPrice.ToString());
            }
            else if (this.ProductCategory == "lens")
            {
                LensBUS db = new LensBUS();
                Lens obj = db.GetById(productId);
                this.ProductId = obj.lensId;
                this.Name = obj.lensNames;
                this.Description = obj.lensDetails;
                this.Image = obj.lensImages;
                this.Price = decimal.Parse(obj.lensPrice.ToString());
            }
            else
            {
                CameraBUS db = new CameraBUS();
                Camera obj = db.GetById(productId);
                this.ProductId = obj.camId;
                this.Name = obj.camNames;
                this.Description = obj.camDetails;
                this.Image = obj.camImages;
                this.Price = decimal.Parse(obj.camPrice.ToString());
            }

        }
    }
}